sui.ready(function() {

})

var vm = new Vue({
	el: "#datas",
	data: {
		currentPage: 1,
		indexs: [],
		allPage: 10,
		tabs: ["门禁预警", "烟感预警", "水浸预警","人孔盖开启预警","超压预计","水箱液位异常预警"],
		selectTab: "门禁预警",


		listDatas: []

	},
	mounted: function() {
		var index = []
		for (var i = 1; i <= this.allPage; i++) {
			index.push(i);
		}
		this.indexs = index;
		this.selectTab = this.tabs[getValue("type") || 0];

		this.pageClick(1);
	},
	methods: {



		pageClick: function(pageIndex) {
			this.currentPage = pageIndex;
			this.getDatas(this.currentPage);
		},
		prevPage: function() {
			this.currentPage--;
			if (this.currentPage < 1) {
				this.currentPage = 1
			}
			this.pageClick(this.currentPage);
		},
		nextPage: function() {
			this.currentPage++;
			if (this.currentPage > 20) {
				this.currentPage = 20
			}
			this.pageClick(this.currentPage);
		},

		tabSelect: function(tab) {
			this.selectTab = tab;
			this.listDatas = [],
			this.pageClick(1);
		},
		
		getDatas: function(page) {
			console.log("第" + page + "页");
			sui.loading();
			var _self = this;
			setTimeout(function() {
				sui.closeLoading();
				_self.setDatas(page);
			}, 1000);
		},
		
		setDatas: function(page) {
			var list = [];
			var begin = (page-1)*10;
			var end = page*10;
			var deals = ["未处理","已处理"];
			
			
			for(var i= begin+1 ; i<= end;i++){
				var w1 = getRandom(2000,4000);
				var w2= getRandom(1000,1567);
				var index = getRandom(1,3) >= 2?1:0
				var deal = deals[index];
				
				list.push({
					id: i,
					time: getRandomDateStr(),
					type: "间歇性预警",
					content: this.selectTab,
					deal: deal,
				})
				
			}
			
			this.listDatas = list;	
		},

	},



})
